import { Component, OnInit } from '@angular/core';
import { CatalogItem } from '../../shared/models/catalog-model';
import { ActivatedRoute } from '@angular/router';
import { CatalogItemService } from '../../shared/services/catalog-list.service';
@Component({
  selector: 'app-home-catalog-list',
  templateUrl: './catalog-list.component.html',
  styleUrls: ['./catalog-list.component.scss'],
  providers:[CatalogItemService]
})
export class CatalogListComponent implements OnInit {

  public catalogItemSets: Array<CatalogItem> = [];


  constructor(
    public catalogItemService: CatalogItemService,
     public activeRoute: ActivatedRoute
  ) { }

  ngOnInit() {
     this.activeRoute.params.subscribe(
      params => {
        if (params) {
          this.GetCatalogItemList();
        }

      }
    );
  }

 public GetCatalogItemList() {
    this.catalogItemService.getRemoteCatalogContents()
      .subscribe(
      datas => {
        this.catalogItemSets = datas;
      },
      error => console.log(error)
      );
  }


}
